<template>
	<view class="passenger-flow">
		<!-- <view class=""
			style="width: 100%;height: 180rpx;background-color: #fff;position: relative;top: 0;z-index: 999;">
			<view class="con-1">
				<view class="bg">
					<view class="address">
						<view class="flex-space-between">
							<view class="flex-align">
								<van-image v-if="itemChooselist.venue_thumb != ''" width="74rpx" height="74rpx"
									radius="2" style="margin-right: 10rpx;" :src="itemChooselist.venue_thumb" />
								<van-image v-else width="74rpx" height="74rpx" radius="10rpx" fit="cover" style="margin-right: 10rpx;" src="https://img.yzcdn.cn/vant/cat.jpeg" />
								<view>
									<view class="address-name">{{itemChooselist.venue_name}}</view>
									<view class="address-desc">地址:{{itemChooselist.address}}</view>
								</view>
							</view>
							<view class="exchange flex-center flex-column " @click="show_no">
								<van-icon name="exchange" size="16" />
								切换
							</view>
						</view>
					</view>
				</view>
			</view>
		</view> -->

		<view class="box_9">
			<!-- <view class="box_11">
				<view class="image-wrapper_7">
					<u-search @search="search" @custom="search" placeholder="搜索" :showAction="false"
						v-model="searchKey">
					</u-search>
				</view>
				<view class="label_list" @click="tianjiaclick">
					<image
						src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/0555f554c12d0d628b0e4e3e90147966755aa715.png"
						class="label_7"></image>
					<view class="label_77">
						添加
					</view>
				</view>
				<view class="label8_list" @click="dropdownclick">
					<image
						src="https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/a0caafa1d0f5c11490a41f203aab143debf439d6.png"
						class="label_8"></image>
					<view class="label_88">
						
						<HM-filterDropdown :menuTop="88" :filterData="filterData" :defaultSelected="defaultSelected"
							:updateMenuName="true" @confirm="confirm" dataFormat="Object"></HM-filterDropdown>
					</view>
				</view>
			</view> -->

			<!-- <view class="">
				<u-sticky>
					<u-tabs :list="tabsList_s" lineColor="#FF4040" :activeStyle="{
									color: '#000000'
								}" :inactiveStyle="{
									color: '#353535'
								}" :lineWidth="30" :current="current_Tab" />
				</u-sticky>
			</view> -->
			<!-- <view class="tag-list">
				<u-tag v-for="(mark, markIndex) in marklist" :key="markIndex"
					:text="mark.name" :borderColor=" '#FF4105'"
					:bgColor="'rgba(255,65,5,0.2)'"
					:color=" '#FF4105'" size="mini"></u-tag>
			</view> -->
			<view class="tag-list">
				<u-search @search="search" @custom="search" placeholder="搜索" :showAction="false"
					v-model="searchKey">
				</u-search>
			</view>

			<!-- 选择会员 -->
			<scroll-view scroll-y class="list">
				<van-checkbox-group :value="selectList" @change.native="change">
					<view class="item" v-for="(item,index) in studentlist" :key="index" style="position: relative;">
						<!-- studentlist -->
						<view class="" style="width: 80%;">
							<!-- @change="onChange" -->
							<van-checkbox checked-color="#635df7" icon-size="40rpx" :name="index" @change="onChange"
								:disabled="item.is_leave == 2">
								<view class="section_6" style="width: 90%;" @click='toggle(item)'>
									<view class="single-avatar_1">
										<image :src="item.head_img" mode="" @click='head_toggle(item)'></image>
									</view>
									<view class="group_5">
										<view class="box_1">
											<text lines="1" class="text_8">{{item.name}}</text>
											<view class="tag_1">
												<text lines="1" class="text_9">黄金会员</text>
											</view>
										</view>
										<!-- <text lines="1" class="text_10">15654577841</text> -->
										<view class="tag-list">
											<u-tag v-for="(mark, markIndex) in marklist" :key="markIndex"
												:text="mark.name" :borderColor="mark.id == 2 ? '#F1F3F6' : '#F1F3F6'"
												:bgColor="mark.id == 2 ? '#F1F3F6' : '#F1F3F6'"
												:color="mark.id == 2 ? '#4F78B5' : '#BEBDBD'" size="mini"></u-tag>
										</view>
									</view>
									<!-- <view class="tag_2">
										<text lines="1" class="text_11">卡</text>
									</view> -->
									<view class="group_6">
										<view class="button_2">
											<text lines="1" class="text_12">愿望与</text>
										</view>
									</view>
								</view>
							</van-checkbox>
						</view>
						<view class="" style="width: 88%;height: 100%;position: absolute;left: 0;top: 0;"
							v-if="item.is_leave == 2 && currentTab == 0">
						</view>
						<view class="" style="width: 100%;height: 100%;position: absolute;left: 0;top: 0; "
							v-if="item.is_leave == 2 && currentTab == 1">
						</view>
					</view>
				</van-checkbox-group>
			</scroll-view>
		</view>
		<!-- 底部 -->
		<view class="footer">
			<view class="flex-space-between">
				<van-checkbox :value="isAllSelect" checked-color="#635df7" icon-size="40rpx" @change.native="allChange">

					<view class="label">全选</view>

				</van-checkbox>
				<view class="">
					<button type="default"
						style="width: 225rpx;height: 70rpx;font-size: 26rpx;background: linear-gradient(0deg, rgba(255,64,64,0.93), rgba(255,64,64,0.93), rgba(250,142,142,0.93));color: #ffffff;">好礼赠送</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const personal = require("@/api/personal/index.js");
	export default {
		data() {
			return {
				lineChartData: {},
				show: false,
				venuelist: [], //场馆列表
				itemChoose: {}, // 场馆数据
				itemChooselist: {}, // 场馆数据
				dropdownmenu: false,
				dateActives: '',
				currentTab: 0,
				current_Tab: 0,
				tabsList: [{
						name: '散客'
					},
					{
						name: '计次卡'
					},
					{
						name: '时间卡'
					},
					{
						name: '充值卡'
					},
					{
						name: '私教卡'
					},
					{
						name: '场地'
					},
					{
						name: '培训'
					},
					{
						name: '赛事'
					}
				],
				tabsList_s: [{
					name: '会员管理'
				}],
				studentlist: [{
						head_img: "https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/c7/2f68e33cb78b34dd21693863f714fb.jpg?attname=tmp_90a01b9bd3e863934b6a0a1cac82ba33.jpg",
						is_leave: 1,
						is_point: 1,
						mobile: "",
						name: "戴晓龙",
						id: 1
					},
					{
						head_img: "https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/c7/2f68e33cb78b34dd21693863f714fb.jpg?attname=tmp_90a01b9bd3e863934b6a0a1cac82ba33.jpg",
						is_leave: 1,
						is_point: 1,
						mobile: "",
						name: "李杰",
						id: 3
					}
				],
				selectList: [],
				isAllSelect: false, //是否全选
				bgMenuShow: false, //全局菜单弹窗
				selectItemId: -1,
				showMenu: true,
				type: '1',
				defaultSelected: [],
				filterData: [],
				marklist: [{
					name: "票",
					id: 2
				}, {
					name: "计次",
					id: 2
				}, {
					name: "时间",
					id: 1
				}, {
					name: "充值",
					id: 2
				}, {
					name: "场地",
					id: 2
				}, {
					name: "培",
					id: 1
				}, {
					name: "私",
					id: 2
				}, {
					name: "赛",
					id: 1
				}],
				marklist: [{
					name: "普通会员",
					id: 2
				}, {
					name: "线上计次卡",
					id: 2
				}, {
					name: "今日办卡",
					id: 1
				}]
			}
		},
		onLoad(options) {
			// 场馆数组
			if (uni.getStorageSync("entry_name") == '') {
				uni.showToast({
					title: '请登录！',
					icon: 'exception',
					duration: 850
				});
				setTimeout(() => {
					uni.navigateTo({
						url: '/pages/my-center/my-center'
					})
				}, 1000);
			}
			var data = uni.getStorageSync("wqzdy");
			var items = JSON.parse(data)
			this.venuelist = items
			this.itemChooselist = this.venuelist[0]
		},
		methods: {
			confirm(e) {
				// this.indexArr = e.index;
				// this.valueArr = e.value;

			},
			tianjiaclick() {
				uni.navigateTo({
					url: './member_Details/edit_members'
				})
			},
			change(event) {
				this.selectList = event.detail
				this.applicantlist = []
				this.selectList.forEach((ex, ix) => {
					this.studentlist.forEach((el, idx) => {
						if (ix == idx) {
							this.applicantlist.push(el.id)
						}
					})
				})
			},
			allChange(event) {
				this.isAllSelect = event.detail
				if (this.isAllSelect) {
					this.selectList = []
					this.studentlist.forEach((item, index) => {
						if (item.is_leave != 2) {
							this.selectList.push(index.toString())
						}
					})
					this.selectList = this.selectList
					this.applicantlist = []
					this.studentlist.forEach((el, idx) => {
						if (el.is_leave != 2) {
							this.applicantlist.push(el.id)
						}
					})
				} else {
					this.selectList = []
					this.applicantlist = []
				}
			},
			head_toggle(item) {
				this.pan_img = true
				this.court_pic = item.head_img
			},
			// 图片放大
			handledownload(item) {
				const that = this
				wx.downloadFile({
					url: court_pic,
					success: res => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: '保存成功',
										duration: 2000
									})

								},
								fail: function() {
									uni.showToast({
										title: '保存失败',
										duration: 2000
									})

								}
							})
						} else {
							uni.showToast({
								title: '保存失败',
								duration: 2000
							})
						}
					}
				})
			},
			toggle(item) {
				item.checked = !item.checked
				this.selectItemId = ''
				this.applicantlist = []
				this.studentlist.forEach((el, idx) => {
					if (el.checked) {
						this.applicantlist.push(el.id)
					}

				})
				// this.applicant = this.applicantlist.toString()
			},
			handOpenMenu(index) {
				this.selectItemId = index
			},
			async analyse() {
				let params = {
					venue_id: this.itemChooselist.id,
					sourceTab: this.nac
				};
				let res = await personal.analyse(params);
				if (res.code == 1) {
					this.lineChartData = res.data.lineChartData
				}
			},
			// 蒙版关闭
			dropdownmenulist() {
				this.dropdownmenu = false
			},
			// 打开蒙版/选择
			dropdownclick() {
				// this.dropdownmenu = true
				// uni.navigateTo({
				// 	url: './shaixuan'
				// })
			},
			onClickTab({
				index
			}) {
				this.currentTab = index;
				this.selectItemId = ''
			},
			// 分类点击
			fieldclick(item, index) {
				this.dateActive = index
				setTimeout(() => {
					this.dropdownmenu = false
				}, 200)
			},
			commoditylist(item, index) {
				uni.navigateTo({
					url: './commodity_product'
				})
			},
			// 分类点击
			fieldclicks(item, index) {
				this.dateActives = index
			},
			merchantclick(item, index) {},
			selectclick(item, index) {},
			// 选中场馆
			onChangelist(item) {
				this.itemChoose = item
				this.lineChartData = []
				this.itemChooselist = this.itemChoose
				this.show = false

			},
			// 点击切换
			show_no() {
				this.show = true
			},
			// 关闭选择场馆弹窗
			showclose() {
				this.show = false
			},
		
		}
	}
</script>

<style lang="scss" scoped>
	@import '../../static/css/member/member_index.scss';
</style>